//
//  RestServiceClient.m
//  CareGiver
//
//  Created by Guillermo Moral on 8/23/14.
//  Copyright (c) 2014 Humana. All rights reserved.
//

#import "RestServiceClient.h"
#import "ResourceModel.h"

@implementation RestServiceClient

- (id)init {
    self = [super init];
    if(self) {
        self.headers = [[NSMutableDictionary alloc]initWithCapacity:0];
        self.params = [[NSMutableDictionary alloc]initWithCapacity:0];
    }
    return self;
}

-(id)initWithDelegate:(id<RestServiceClientDelegate>)delegate
     serviceNamespace:(NSString*)ns
          serviceName:(NSString*)name {
    self = [self init];
    if(self) {
        self.delegate = delegate;
        [self setServiceDefinitions:ns name:name];
    }
    return self;
}

- (void)setServiceDefinitions:(NSString*)ns name:(NSString*)name {
    
}

- (void)executeRequest {
    
    // First Time
    if([self.params count]>0) {
        if ([_delegate respondsToSelector:@selector(serviceRequestReceiveData:)]) {
            [_delegate serviceRequestReceiveData:[self createMoc]];
        }
    } else {
        if ([_delegate respondsToSelector:@selector(serviceRequestReceiveData:)]) {
            [_delegate serviceRequestReceiveData:[self createMoc2]];
        }
    }
}

-(NSArray*)createMoc {
    NSMutableArray *resourcesData = [NSMutableArray new];
    ResourceModel *r1 = [[ResourceModel alloc]initKey:@"1" organization:@"Clarin" address1:@"Papa" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r2 = [[ResourceModel alloc]initKey:@"2" organization:@"LA Nacion" address1:@"Pepe" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r3 = [[ResourceModel alloc]initKey:@"3" organization:@"El Territorio" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r4 = [[ResourceModel alloc]initKey:@"4" organization:@"O GLobo" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r5 = [[ResourceModel alloc]initKey:@"5" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r6 = [[ResourceModel alloc]initKey:@"6" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r7 = [[ResourceModel alloc]initKey:@"7" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
   
    [resourcesData addObject:r1];
    [resourcesData addObject:r2];
    [resourcesData addObject:r3];
    [resourcesData addObject:r4];
    [resourcesData addObject:r5];
    [resourcesData addObject:r6];
    [resourcesData addObject:r7];
    
    return [resourcesData mutableCopy];
    
}

-(NSArray*)createMoc2 {
    NSMutableArray *resourcesData = [NSMutableArray new];
    ResourceModel *r1 = [[ResourceModel alloc]initKey:@"8" organization:@"Clarin" address1:@"Papa" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r2 = [[ResourceModel alloc]initKey:@"9" organization:@"LA Nacion" address1:@"Pepe" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r3 = [[ResourceModel alloc]initKey:@"10" organization:@"El Territorio" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r4 = [[ResourceModel alloc]initKey:@"11" organization:@"O GLobo" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r5 = [[ResourceModel alloc]initKey:@"12" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r6 = [[ResourceModel alloc]initKey:@"13" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    ResourceModel *r7 = [[ResourceModel alloc]initKey:@"14" organization:@"Papelitp" address1:@"" address2:@"" latitude:@"38.256376" longitude:@"-85.753438"];
    
    [resourcesData addObject:r1];
    [resourcesData addObject:r2];
    [resourcesData addObject:r3];
    [resourcesData addObject:r4];
    [resourcesData addObject:r5];
    [resourcesData addObject:r6];
    [resourcesData addObject:r7];
    
    return [resourcesData mutableCopy];
    
}



@end
